package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FxyFinancialVoucherWord;
import com.ruoyi.system.service.IFxyFinancialVoucherWordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 凭证字Controller
 * 
 * @author ruoyi
 * @date 2025-01-16
 */
@RestController
@RequestMapping("/system/word")
public class FxyFinancialVoucherWordController extends BaseController
{
    @Autowired
    private IFxyFinancialVoucherWordService fxyFinancialVoucherWordService;

    /**
     * 查询凭证字列表
     */

    @GetMapping("/list/{setsId}")
    public TableDataInfo list(@PathVariable Integer setsId)
    {
        startPage();
        List<FxyFinancialVoucherWord> list = fxyFinancialVoucherWordService.selectFxyFinancialVoucherWordList(setsId);
        return getDataTable(list);
    }

    /**
     * 导出凭证字列表
     */

    /**
     * 获取凭证字详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:word:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxyFinancialVoucherWordService.selectFxyFinancialVoucherWordById(id));
    }

    /**
     * 新增凭证字
     */
    @PreAuthorize("@ss.hasPermi('system:word:add')")
    @Log(title = "凭证字", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FxyFinancialVoucherWord fxyFinancialVoucherWord)
    {
        return toAjax(fxyFinancialVoucherWordService.insertFxyFinancialVoucherWord(fxyFinancialVoucherWord));
    }

    /**
     * 修改凭证字
     */
    @PreAuthorize("@ss.hasPermi('system:word:edit')")
    @Log(title = "凭证字", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FxyFinancialVoucherWord fxyFinancialVoucherWord)
    {
        return toAjax(fxyFinancialVoucherWordService.updateFxyFinancialVoucherWord(fxyFinancialVoucherWord));
    }

    /**
     * 删除凭证字
     */
    @PreAuthorize("@ss.hasPermi('system:word:remove')")
    @Log(title = "凭证字", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxyFinancialVoucherWordService.deleteFxyFinancialVoucherWordByIds(ids));
    }
}
